package total;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
/**
 *   0  1  2  3  4  5  6  7
 * 0 A  0  0  0  0  0  0  0
 * 1 0  0  0  0  0  0  0  0
 * 2 0  0  0  0  0  0  0  0
 * 3 0  0  0  0  0  0  0  0
 * 4 0  0  0  0  0  0  0  0
 * 5 0  0  0  0  0  0  0  0
 * 6 0  0  0  0  0  C  0  0
 * 7 0  0  0  0  0  0  B  0
 * @author chenxiaokang
 *
 */
public class Ques1639 {
	
	Node a,b,c,temp;
	int[][] board;
	Queue<Node> queue;
	int num;
	
	public void bfs(){
		outter:while(true){
			this.temp = queue.poll();
//			System.out.println("x:"+temp.x+"   "+"y:"+temp.y+"     "+board[temp.x][temp.y]);
			for(int i = -1;i < 2;i ++){
				for(int j = -1;j < 2;j ++){
					if(this.temp.x == b.x && this.temp.y == b.y){
						System.out.println(board[this.temp.x][this.temp.y] - 1);
						break outter;
					}
					if(i == 0 && j == 0){
						continue;
					}
					if(this.temp.x + i < 0 || this.temp.x + i > 7 || this.temp.y + j < 0 || this.temp.y + j > 7){
						continue;
					}else{
						if(board[this.temp.x + i][this.temp.y + j] == 0){
							num = board[temp.x][temp.y];
							board[this.temp.x + i][this.temp.y + j] = ++num;
							queue.add(new Node(this.temp.x + i,this.temp.y + j));
						}
					}
				}
			}
		}
	}
	
	public void go(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			this.a = new Node();
			this.b = new Node();
			this.c = new Node();
			queue = new LinkedList<Node>();
			this.a.x = scan.nextInt() - 1; 
			this.a.y = scan.nextInt() - 1;
			this.b.x = scan.nextInt() - 1;
			this.b.y = scan.nextInt() - 1;
			this.c.x = scan.nextInt() - 1;
			this.c.y = scan.nextInt() - 1;
			this.queue.add(a);
			this.board = new int[8][8];
			this.board[this.c.x][this.c.y] = -1;
			this.board[this.a.x][this.a.y] = 1;
			this.bfs();
		}
	}
	
	public static void main(String[] args) {
		new Ques1639().go();
	}
	
	class Node{
		int x,y;
		public Node(int x,int y){
			this.x = x;
			this.y = y;
		}
		public Node(){}
	}
}
